From: Chong Yidong Date: Sat, 4 Dec 2010 22:10:12 +0000 (-0500) Subject: Smarter initialization for dired-use-ls-dired (Bug#7546). X-Git-Tag: archive/raspbian/1%29.2+1-2+rpi1~1^2~324^2~5461 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https:/www.github.com/%22bookmarks:///%22http:/www.example.com/cgi/%22https:/www.github.com/%22bookmarks:/?a=commitdiff_plain;h=56eac2b3208366a667b03d18ea27a64d27b8c6a7;p=emacs.git Smarter initialization for dired-use-ls-dired (Bug#7546). * lisp/dired.el (dired-use-ls-dired): Set default to a special "unspecified" value. (dired-insert-directory): When called the first time, check whether "ls --dired" succeeds and set dired-use-ls-dired (Bug#7546). --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 18335c0ae95..2f7e7bfe61e 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,10 @@ +2010-12-04 Chong Yidong + + * dired.el (dired-use-ls-dired): Set default to a special + "unspecified" value. + (dired-insert-directory): When called the first time, check + whether "ls --dired" succeeds and set dired-use-ls-dired (Bug#7546). + 2010-12-04 Tak Ota * replace.el: Add "collect" feature to occur. diff --git a/lisp/dired.el b/lisp/dired.el index 104cf4970ad..8012fcb472d 100644 --- a/lisp/dired.el +++ b/lisp/dired.el @@ -80,8 +80,11 @@ If nil, `dired-listing-switches' is used.") "/etc/chown"))) "Name of chown command (usually `chown' or `/etc/chown').") -(defvar dired-use-ls-dired (not (not (string-match "gnu" system-configuration))) - "Non-nil means Dired should use `ls --dired'.") +(defvar dired-use-ls-dired 'unspecified + "Non-nil means Dired should use \"ls --dired\". +The special value of `unspecified' means to check explicitly, and +save the result in this variable. This is performed the first +time `dired-insert-directory' is called.") (defvar dired-chmod-program "chmod" "Name of chmod command (usually `chmod').") @@ -1057,7 +1060,14 @@ If HDR is non-nil, insert a header line with the directory name." (let ((opoint (point)) (process-environment (copy-sequence process-environment)) end) - (if (or dired-use-ls-dired (file-remote-p dir)) + (if (or (if (eq dired-use-ls-dired 'unspecified) + ;; Check whether "ls --dired" gives exit code 0, and + ;; save the answer in `dired-use-ls-dired'. + (setq dired-use-ls-dired + (eq (call-process insert-directory-program nil nil nil "--dired") + 0)) + dired-use-ls-dired) + (file-remote-p dir)) (setq switches (concat "--dired " switches))) ;; We used to specify the C locale here, to force English month names; ;; but this should not be necessary any more,